<%@ page import="java.util.List" %>
<%@ page import="com.example.demo_text.EnrollmentDAO" %>
<%@ page import="user.StudentEnrollment" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
  <title>选课管理</title>
  <style>
    /* 全局样式 */
    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: 'Segoe UI', 'PingFang SC', 'Microsoft Yahei', sans-serif;
      background: linear-gradient(135deg, #e0f7fa, #f3e5f5);
      min-height: 100vh;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 40px 20px;
      color: #333;
    }

    .card {
      background: white;
      width: 100%;
      max-width: 600px;
      padding: 30px 25px;
      border-radius: 16px;
      box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
      transition: all 0.3s ease;
      text-align: center;
    }

    .card:hover {
      transform: translateY(-5px);
      box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    }

    h2 {
      text-align: center;
      margin-bottom: 24px;
      font-weight: 600;
      color: #374151;
    }

    .btn {
      width: 100%;
      padding: 12px 20px;
      background-color: #d1ecf1;
      color: #15576b;
      border-radius: 8px;
      text-decoration: none;
      font-weight: 500;
      transition: background 0.3s, color 0.3s;
      text-align: center;
      box-sizing: border-box;
    }

    .btn:hover {
      background-color: #aee2eb;
      color: #0f3d4d;
    }

    .back-link {
      display: block;
      text-align: center;
      margin-top: 20px;
      color: #3498db;
      text-decoration: underline;
      font-size: 14px;
    }

    .back-link:hover {
      color: #2980b9;
    }
  </style>

</head>
<body>

<div class="card">
  <h2>选课管理</h2>
  <table>
    <thead>
    <tr>
      <th>用户名</th>
      <th>课程名称</th>
      <th>操作</th>
    </tr>
    </thead>
    <tbody>
    <% List<StudentEnrollment> enrollments = EnrollmentDAO.getAllEnrollments(); %>
    <% for (StudentEnrollment e : enrollments) { %>
    <tr>
      <td><%= e.getUserName() %></td>
      <td><%= e.getCourseName() %></td>
      <td>
        <a href="editEnrollment.jsp?userId=<%= e.getUserId() %>&courseId=<%= e.getCourseId() %>" class="btn">编辑</a>
      </td>
    </tr>
    <% } %>
    </tbody>
  </table>
  <a href="AdmitHome.jsp" class="back-link">返回管理员主页</a>
</div>

</body>
</html>
